home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / BatchProcess.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1997-02-02  |  18.4 KB  |  573 lines

  1. /*
  2. ** $VER: BatchProcess.rexx 2.25
  3. ** Copyright © by Patrik M Nydensten
  4. ** 2/2 1997 Stockholm/Sweden
  5. **
  6. ** IE batch script exectuter for Image Engineer 3.4 and
  7. ** ArexxSupport module 2.1 or higher.
  8. ** Batch processes selected image files and saves them into a selected
  9. ** destination directory. Uses IE Batch scripts.
  10. */
  11.  
  12. /* Config settings */
  13.  
  14. CFG_CONFIG_FILE = 'IE:Cfg/BatchProcess.cfg'
  15.  
  16. CFG_SRC_DIR = 'IE:'
  17. CFG_DEST_DIR = 'RAM:'
  18. CFG_MAX_BS = 3
  19.  
  20. do i = 1 to CFG_MAX_BS
  21.   CFG_BATCH_SCRIPT.i = 'IE:Arexx/Batch/'
  22.   CFG_BU.i = 0
  23.   CFG_SEC_DIR.i = 'IE:'
  24.   CFG_ALP_DIR.i = 'IE:'
  25. end
  26.  
  27. CFG_SAVE_FRMT = 0
  28. CFG_BASE_NAME = 'Output'
  29. CFG_IE_PRI = '-3'
  30.  
  31. /* Main program --------------------------- */
  32.  
  33. /* Variables */
  34.  
  35. NL='0a'x ; DQ='22'x ; SQ='27'x
  36.  
  37. options results
  38. signal on syntax
  39.  
  40. if ~show(ports,'IMAGEENGINEER') then exit
  41. address 'IMAGEENGINEER'
  42.  
  43. /* Read/Setup BP config ------------------- */
  44.  
  45. call read_config()
  46.  
  47. /* Get PRIMARY images --------------------- */
  48.  
  49. call get_multifile('"Select PRIMARY image(s)."','"'CFG_SRC_DIR'"')
  50. parse var result '"'num_files'"' '"'src_filelist'"'
  51.  
  52. /* Handle BP settings window -------------- */
  53.  
  54. do while ok ~= 1
  55.  
  56.   xsrc_filelist = src_filelist ; nil_filelist = '' ; i = 0
  57.   do forever
  58.     parse var xsrc_filelist file ';' xsrc_filelist
  59.     if strip(file) ~= '' then i = i + 1
  60.     else leave
  61.     if i < 6 then nil_filelist = nil_filelist || file || NL
  62.     if i = 6 then nil_filelist = nil_filelist || '[...]' || NL
  63.     prevfile = file
  64.   end
  65.   if i >= 6 then nil_filelist = nil_filelist || prevfile
  66.   else nil_filelist = strip(nil_filelist,'B',NL)
  67.  
  68.   form = 'FORM "BatchProcess 2.2, Image Engineer Batch System" " Go! | File List | Prefs | Exit "',
  69.   ' TEXT,"An IE batch script executer for advanced batch processing.',
  70.   NL'Copyright © 1997 by Patrik M Nydensten"'
  71.  
  72.   do i = 1 to CFG_MAX_BS
  73.     form = form ||' FILE,"Batch script 'i'.","'CFG_BATCH_SCRIPT.i'"',
  74.       ' CYCLE,"Settings:","--|Set for first image only.|Linear mode|Faster mode|Slower mode|Spline mode",'CFG_BU.i
  75.   end
  76.  
  77.   form = form ||' TEXT,"'num_files' images in primary file list:"',
  78.   ' TEXT,"'nil_filelist'"',
  79.   ' DIR,"Destination dir","'CFG_DEST_DIR'"',
  80.   ' STRING,"Output base name","'CFG_BASE_NAME'",25'
  81.  
  82.   form
  83.   if (RC~=0) then do
  84.     'REQUEST' '"Failed to build GUI !"' '" Reset settings | Abort "'
  85.     if result = 1 then address 'COMMAND' 'delete' CFG_CONFIG_FILE 'QUIET FORCE'
  86.     exit
  87.   end
  88.  
  89.   parse var result ok rest
  90.   if ok = 0 then exit
  91.  
  92.   do i = 1 to CFG_MAX_BS
  93.     parse var rest '"'bscript.i'"' bu.i rest
  94.   end
  95.   parse var rest '"'dst_path'"' '"'dst_filename'"'
  96.  
  97.   if ((right(dst_path,1)~=':')&(right(dst_path,1)~='/')) then dst_path = dst_path||'/'
  98.  
  99.   if ok = 2 then call handle_filelist(src_filelist)
  100.   if ok = 3 then call set_config()
  101.  
  102.   /* Write BP config ------------------------ */
  103.  
  104.   call write_config()
  105.   if ok ~=0 then call read_config()
  106.  
  107. end /* main window loop */
  108.  
  109. /* Check batch script --------------------- */
  110.  
  111. do i = 1 to CFG_MAX_BS /* main MB loop */
  112.   if bu.i = 0 then iterate i
  113.  
  114.   binfo.i = bei('INFO')  /* get extra info from batch */
  115.   if word(binfo.i,1) ~= 'OK' then ErrorOut('Error while accessing batch script'NL||bscript.i'!')
  116.  
  117.   /* Get SECONDARY images ----------------- */
  118.  
  119.   if pos('S',binfo.i) ~= 0 then do
  120.     call get_multifile('"Select ('num_files') SECONDARY images for 'get_file(bscript.i)'."','"'CFG_SEC_DIR.i'"')
  121.     parse var result '"'num_sec.i'"' '"'sec_filelist.i'"'
  122.   end
  123.   else do
  124.     num_sec.i = 0 ; sec_filelist.i = '0'
  125.   end
  126.  
  127.   /* Get ALPHA images --------------------- */
  128.  
  129.   if pos('A',binfo.i) ~= 0 then do
  130.     call get_multifile('"Select ('num_files') ALPHA images for 'get_file(bscript.i)'."','"'CFG_ALP_DIR.i'"')
  131.     parse var result '"'num_alp.i'"' '"'alp_filelist.i'"'
  132.   end
  133.   else do
  134.     num_alp.i = 0 ; alp_filelist.i = '0'
  135.   end
  136.  
  137.   /* Get setting(s) for batch script  ----- */
  138.  
  139.   if (num_files > 1)&(bu.i>1) then 'REQUEST' '"Select settings for first image.'NL'Batch script:' get_file(bscript.i)'"' '" Continue "'
  140.   bopt_f.i = bei('CONFIG')
  141.   if (bopt_f.i = '<ERROR>') then ErrorOut('Error while retrieving settings from'NL'batch script' bscript.i'!')
  142.  
  143.   if (num_files > 1)&(bu.i>1) then do
  144.     'REQUEST' '"Select settings for last image.'NL'Batch script:' get_file(bscript.i)'"' '" Continue "'
  145.     bopt_l.i = bei('CONFIG' sq'"'bopt_f.i'"'sq)
  146.     if (bopt_l.i = '<ERROR>') then ErrorOut('Error while retrieving settings from'NL'batch script' bscript.i'!')
  147.     if bu.i > 2 then nil = add_mathlib()
  148.   end
  149.   else bopt_l.i = bopt_f.i
  150.  
  151. end /* end main MB loop */
  152.  
  153. call write_config()
  154.  
  155. /* Start processing  ------------------------------------------------ */
  156.  
  157. 'IE_TO_FRONT'
  158.  
  159. 'PRIORITY_SET' CFG_IE_PRI
  160. OLD_IE_PRI = Result
  161.  
  162. first_batchQ = 1
  163.  
  164. do i = 1 to CFG_MAX_BS  /* MB loop */
  165.   if bu.i = 0 then iterate i
  166.  
  167.   src_filelist_saved = src_filelist
  168.   sec_filelist_saved.i = sec_filelist.i
  169.   alp_filelist_saved.i = alp_filelist.i
  170.  
  171.   do j = 1 to num_files  /* Process loop */
  172.  
  173.     parse var src_filelist image_file ';' src_filelist
  174.     if first_batchQ = 0 then image_file = dst_path||dst_filename||'.'||right(j,4,'0')
  175.  
  176.     bei_proc = 'PROCESS' sq'"'image_file'"'sq sq'"'dst_path||dst_filename||'.'||right(j,4,'0')'"'sq sq'"'calc_bopt(j)'"'sq get_info_add()
  177.     Result = bei(bei_proc)
  178.  
  179.     if Result = '<ERROR>' then do
  180.       'REQUEST' '"Batch script' bscript.i 'returned error while'NL||'processing image' j',' image_file'"' '" Continue | Abort "'
  181.       if (Result = 0) then exit
  182.     end
  183.   end  /* end process loop */
  184.  
  185.   first_batchQ = 0
  186.  
  187. end  /* end of MB loop */
  188.  
  189. 'IE_TO_FRONT'
  190. 'PRIORITY_SET' OLD_IE_PRI
  191. 'REQUEST' '" Batch process finished. "' '" Nice! "'
  192.  
  193. exit
  194.  
  195. /* Procedures  ------------------------------------------------------*/
  196.  
  197. /* Batch script caller */
  198.  
  199. BEI:
  200.   parse arg bei_input
  201.  
  202.   if ~exists(bscript.i) then ErrorOut('Failed to load batch script:'NL||bscript.i)
  203.   else interpret 'CALL' '"'bscript.i'"' bei_input
  204.   bei_output = RESULT
  205.  
  206.   address 'IMAGEENGINEER'
  207. return bei_output
  208.  
  209. /* Config settings twiner  ---------------- */
  210.  
  211. calc_bopt:
  212.   parse arg cur_filenum
  213.   calc_output = ''
  214.   bopt_fx = bopt_f.i ; bopt_lx = bopt_l.i
  215.   if (bu.i = 1) then calc_output = bopt_fx
  216.   else do forever
  217.     parse var bopt_fx val_fx bopt_fx
  218.     parse var bopt_lx val_lx bopt_lx
  219.     val_fx = strip(val_fx) ; val_lx = strip(val_lx)
  220.     if ((val_fx='OK')|(val_lx='OK')) then leave
  221.     if ((val_fx='')|(val_lx='')) then leave
  222.     if ((left(val_fx,1)='#')|(left(val_lx,1)='#')) then calc_output = calc_output val_fx
  223.     else do   /* mode calc */
  224.       select
  225.         when bu.i = 2 then calc_output = calc_output trunc( (val_fx+(val_lx - val_fx)*(cur_filenum-1)/(num_files-1)) )
  226.         when bu.i = 3 then calc_output = calc_output trunc( val_fx+(val_lx-val_fx)*( (exp((-1)+5*(cur_filenum-1)/(num_files-1))-exp(-1)) /exp(4))/0.993262053 )
  227.         when bu.i = 4 then calc_output = calc_output trunc( val_fx+(val_lx-val_fx)*(1-( exp(4-5*(cur_filenum-1)/(num_files-1)) /exp(4)))*1.006783655 )
  228.         when bu.i = 5 then calc_output = calc_output trunc( val_lx-(((cos(3.14159265*(cur_filenum-1)/(num_files-1))+1)/2)*(val_lx-val_fx)) )
  229.         otherwise nop
  230.       end
  231.     end /* end mode calc */
  232.   end
  233. return strip(calc_output)
  234.  
  235. /* Output optional extra info if needed --- */
  236.  
  237. get_info_add:
  238.   info_output = ''
  239.  
  240.   if pos('S',binfo.i)~=0 then do
  241.     do until strip(file)~=''
  242.       parse var sec_filelist.i file ';' sec_filelist.i
  243.       if file = '' then sec_filelist.i = sec_filelist_saved.i
  244.     end
  245.     info_output = sq'"'strip(file,B,'"')'"'sq
  246.   end
  247.  
  248.   if pos('A',binfo.i)~=0 then do
  249.     do until strip(file)~=''
  250.       parse var alp_filelist.i file ';' alp_filelist.i
  251.       if file = '' then alp_filelist.i = alp_filelist_saved.i
  252.     end
  253.     info_output = info_output sq'"'strip(file,B,'"')'"'sq
  254.   end
  255.  
  256.   if pos('F',binfo.i)~=0 then do
  257.     info_output = info_output sq'"'j':'num_files'"'sq
  258.   end
  259.  
  260. return strip(info_output)
  261.  
  262. /* Get MultiFile -------------------------- */
  263.  
  264. get_multifile: PROCEDURE EXPOSE NL
  265.   parse arg '"'gmf_title'"','"'gmf_dir'"'
  266.  
  267.   'GET_FILES' '"'gmf_title'"' '" OK "' '"'gmf_dir'"'
  268.   gmf_filelist = compress(strip(RESULT),'"')
  269.   if (gmf_filelist=''|RC=5) then exit
  270.  
  271.   /* ReBuild file list */
  272.  
  273.   xgmf_filelist=''; n=0
  274.   do forever
  275.     parse var gmf_filelist file ';' gmf_filelist
  276.     if strip(file)='' then leave
  277.     if (upper(right(file,5))='.LIST') then do
  278.       call read_list_file(file)
  279.       parse var result '"'num_nil'"' '"'nil_filelist'"'
  280.       xgmf_filelist = xgmf_filelist||nil_filelist';'
  281.       n=n+num_nil
  282.     end
  283.     else do
  284.       xgmf_filelist = xgmf_filelist||file';'
  285.       n=n+1
  286.     end
  287.   end
  288.   gmf_filelist=strip(xgmf_filelist,'B',';'); num_gmf=n
  289.  
  290.   /* Ask for cloning of single image */
  291.  
  292.   if num_gmf = 1 then do
  293.     'FORM "File cloning question" " Accept | Cancel "',
  294.     ' TEXT,"You have only selected one single image. Select the number of clones (copies) of the file',
  295.     NL||'`'gmf_filelist'`, that you would like to use."',
  296.     ' INTEGER,"Number of clones",2,100,10,SLIDER',
  297.     ' INTEGER,"... plus",0,9899,0,SLIDER'
  298.  
  299.     parse var result ok gmf_clones gmf_clonesb
  300.     if ok = 0 then exit
  301.     gmf_clones = gmf_clones + gmf_clonesb
  302.  
  303.     xgmf_filelist = ''
  304.     do n = 1 to gmf_clones
  305.       xgmf_filelist = xgmf_filelist || gmf_filelist || ';'
  306.     end
  307.     gmf_filelist = strip(xgmf_filelist,'B',';')
  308.     num_gmf = gmf_clones
  309.  
  310.   end /* cloning */
  311.  
  312.   /* Ask for index range selection */
  313.  
  314.   if num_gmf = 2 then do
  315.     parse var gmf_filelist file_1 ';' file_2 ';'
  316.     call check_index_range(file_1,file_2)
  317.     parse var result '"'num_gmf'"' '"'gmf_filelist'"'
  318.   end
  319.  
  320.   if num_gmf < 2 then ErrorOut('Bad number of selected files!')
  321. return '"'num_gmf'"' '"'gmf_filelist'"'
  322.  
  323. check_index_range: PROCEDURE EXPOSE NL
  324.   parse arg file_1, file_2
  325.  
  326.   base = get_base(file_1)'.'
  327.   base_2 = get_base(file_2)'.'
  328.   ix_1 = get_ext(file_1) ; zlen = length(ix_1)
  329.   ix_2 = get_ext(file_2)
  330.   if (base=base_2)&(datatype(ix_1,'N'))&(datatype(ix_2,'N'))&(ix_2-ix_1>1) then do
  331.     'REQUEST' '"You have selected two images, both with the same base name'NL||,
  332.       'and both with an index number. Would you like to include all'NL||,
  333.       'images within the index range?  ('ix_2-ix_1+1' images)'NL||NL||,
  334.       '('base',' ix_1 'and' ix_2')"' '"Yes, index range|No, two images"'
  335.     if (Result = 1) then do
  336.       range_list = '' ; index_fix = 0
  337.       do n = strip(ix_1,L,'0') to strip(ix_2,L,'0')
  338.         if ~exists(base || right(n,zlen,'0')) then do
  339.           if skip_all ~= 1 then do
  340.             'REQUEST' '"Could not locate file:'NL ||base||right(n,zlen,'0')'"' '"Skip image|Skip all|Abort action"'
  341.             if Result ~= 0 then index_fix = index_fix + 1
  342.             if Result = 2 then skip_all = 1
  343.             if Result = 0 then exit
  344.           end
  345.           else index_fix = index_fix + 1
  346.         end
  347.         else range_list = range_list || base || right(n,zlen,'0')||';'
  348.       end
  349.       num_range = ix_2 - ix_1 + 1 - index_fix
  350.       if (index_fix>0) then 'REQUEST' '"Skipped' index_fix 'images.' num_range 'images found."' '"Continue"'
  351.       if num_range < 2 then exit
  352.     end  /* Do index range? */
  353.     else do; range_list = file_1';'file_2 ; num_range=2 ; end
  354.   end  /* Index files? */
  355. return '"'num_range'"' '"'range_list'"'
  356.  
  357. read_list_file: PROCEDURE EXPOSE NL
  358.   parse arg rlf_file
  359.   num_rlf = 0; rlf_filelist = ''
  360.   if open(rlf_file,rlf_file,'R') then do
  361.     do forever
  362.       read = strip(readln(rlf_file),B,'"')
  363.       if strip(read) = '' then leave
  364.       if ~exists(read) then do
  365.         'REQUEST' '"File list error on line' num_rlf+1'. Could not load'NL'file `'read'`.'NL||NL'('rlf_file')"' '" Continue "'
  366.         iterate
  367.       end
  368.       if (upper(right(read,5))='.LIST') then do
  369.         call read_list_file(read)
  370.         parse var result '"'num_nil'"' '"'nil_filelist'"'
  371.         rlf_filelist = rlf_filelist||nil_filelist';'
  372.         num_rlf=num_rlf+num_nil
  373.       end
  374.       else do
  375.         num_rlf = num_rlf+1; rlf_filelist = rlf_filelist||read||';'
  376.       end
  377.     end
  378.     'REQUEST' '"The' rlf_file||NL'file list resulted in' num_rlf 'loaded files."' '" Continue "'
  379.     call close(rlf_file)
  380.     if num_rlf = 0 then 'REQUEST' '"File list `'rlf_file'` is empty."' '" OK "'
  381.   end
  382.   else 'REQUEST' '"Failed to access file list `'rlf_file'`.'NL'Looped linking?"' '" OK "'
  383.   if num_rlf = 2 then do
  384.     parse var rlf_filelist file_1 ';' file_2 ';'
  385.     call check_index_range(file_1,file_2)
  386.     parse var result '"'num_rlf'"' '"'rlf_filelist'"'
  387.   end
  388. return '"'num_rlf'"' '"'strip(rlf_filelist,'B',';')'"'
  389.  
  390. /* Config read/write/set ------------------ */
  391.  
  392. read_config:
  393.     if exists(CFG_CONFIG_FILE) then do
  394.         if open('cfg',CFG_CONFIG_FILE,'R') then do
  395.             if readln('cfg')='BPCFGV:1' then do
  396.                 CFG_SRC_DIR = readln('cfg')
  397.                 CFG_DEST_DIR = readln('cfg')
  398.                 CFG_MAX_BS = readln('cfg')
  399.                 do i = 1 to CFG_MAX_BS
  400.                     CFG_BATCH_SCRIPT.i = readln('cfg')
  401.                      CFG_BU.i = readln('cfg')
  402.                     CFG_SEC_DIR.i = readln('cfg')
  403.                     CFG_ALP_DIR.i = readln('cfg')
  404.           sec_filelist.i = ''
  405.           alp_filelist.i = ''
  406.                 end
  407.                 CFG_SAVE_FRMT = readln('cfg')
  408.                 CFG_BASE_NAME = readln('cfg')
  409.                 CFG_IE_PRI = readln('cfg')
  410.             end
  411.             call close('cfg')
  412.         end
  413.     end
  414.   sf = CFG_SAVE_FRMT; select
  415.     when sf = 1 then sf = 'ILBM uncompressed'
  416.     when sf = 2 then sf = 'DEEP'
  417.     when sf = 3 then sf = 'YUVN (411)'
  418.     otherwise do; sf = 'ILBM CmpByteRun1'; CFG_SAVE_FRMT=0; end
  419.   end; call setclip('cfg_save_frmt',sf)
  420. return 'OK'
  421.  
  422. write_config:
  423.     if open('cfg',CFG_CONFIG_FILE,'W') then do
  424.         call writeln('cfg','BPCFGV:1')
  425.         parse var src_filelist nil ';' xnil
  426.         call writeln('cfg',get_path(nil))
  427.         call writeln('cfg',dst_path)
  428.         call writeln('cfg',strip(CFG_MAX_BS))
  429.         do i = 1 to CFG_MAX_BS
  430.             if symbol('bscript.'i)='VAR' then call writeln('cfg',bscript.i)
  431.       else call writeln('cfg','IE:ARexx/Batch/')
  432.             if symbol('bu.'i)='VAR' then call writeln('cfg',bu.i)
  433.       else call writeln('cfg','0')
  434.       if sec_filelist.i = '' then call writeln('cfg',CFG_SEC_DIR.i)
  435.             else do
  436.               parse var sec_filelist.i nil ';' xnil
  437.               call writeln('cfg',get_path(nil))
  438.             end
  439.       if alp_filelist.i = '' then call writeln('cfg',CFG_ALP_DIR.i)
  440.             else do
  441.               parse var alp_filelist.i nil ';' xnil
  442.               call writeln('cfg',get_path(nil))
  443.             end
  444.         end
  445.         call writeln('cfg',strip(CFG_SAVE_FRMT))
  446.         call writeln('cfg',strip(dst_filename))
  447.         call writeln('cfg',strip(CFG_IE_PRI))
  448.         call close('cfg')
  449.     end
  450. return 'OK'
  451.  
  452. set_config: PROCEDURE EXPOSE NL CFG_SAVE_FRMT CFG_MAX_BS CFG_IE_PRI
  453.     'FORM "BatchProcess Prefs" " Save | Cancel "',
  454.     ' TEXT,"This is the save file format that is suggested by this executer to the batch scripts.',
  455.     NL'Not all scripts are aware of this option and not all can actually use it."',
  456.     ' CYCLE,"Save format:","ILBM24 CmpByteRun1|ILBM24 uncompressed|DEEP|YUVN (411)",'CFG_SAVE_FRMT,
  457.     ' TEXT,"This is the number of batch script gadgets that are available in the main window."',
  458.   ' INTEGER,"Number of batch scripts",1,30,'CFG_MAX_BS',SLIDER',
  459.     ' TEXT,"This is the task priority that IE will have while processing images."',
  460.   ' INTEGER,"Priority",-10,5,'CFG_IE_PRI',SLIDER'
  461.  
  462.   parse var result ok rest
  463.   if ok = 1 then parse var rest CFG_SAVE_FRMT CFG_MAX_BS CFG_IE_PRI
  464. return 'OK'
  465.  
  466. /* File list proc. ------------------------ */
  467.  
  468. handle_filelist: PROCEDURE EXPOSE NL src_filelist num_files dst_path CFG_SRC_DIR
  469.   parse arg hfl_filelist
  470.   tpfl = 'the primary file list'
  471.   'FORM "BatchProcess File List Handler" " Done | Load | Save | Load dir | Reverse "',
  472.   'TEXT,"Load - selects new files for' tpfl'.'NL||,
  473.   'Save - saves' tpfl 'to disk.'NL||,
  474.   'Load dir - loads all files in a directory to' tpfl'.'NL||,
  475.   'Reverse - changes the order in' tpfl'."'
  476.  
  477.   parse var result hfl_ok '"'save_dir'"'
  478.   if hfl_ok = 1 then return 'OK'
  479.   if hfl_ok = 2 then do
  480.     call get_multifile('"Select PRIMARY image(s)."','"'CFG_SRC_DIR'"')
  481.     parse var result '"'num_files'"' '"'src_filelist'"'
  482.   end
  483.   if hfl_ok = 3 then call write_filelist(hfl_filelist)
  484.   if hfl_ok = 4 then do
  485.     'GET_DIR' '"Select a directory to load."' '" Load dir "'
  486.     if (RC=5) then exit
  487.     parse var result loadd
  488.     address 'COMMAND' 'list >t:BP.list' '"'loadd'"' 'LFORMAT "%p%n" FILES'
  489.     address 'COMMAND' 'sort FROM t:BP.list TO t:BP.list'
  490.     call read_list_file('t:BP.list')
  491.     parse var result '"'num_files'"' '"'src_filelist'"'
  492.   end
  493.   if hfl_ok = 0 then do
  494.     hfl_filelist=''
  495.     do forever
  496.       parse var src_filelist file ';' src_filelist
  497.       if strip(file)='' then leave
  498.       hfl_filelist = file||';'hfl_filelist
  499.     end
  500.     src_filelist=strip(hfl_filelist,'B',';')
  501.   end
  502. return 'OK'
  503.  
  504. write_filelist: PROCEDURE EXPOSE NL dst_path
  505.   parse arg wfl_filelist
  506.   'GET_FILE' '"Enter a file list name to save."' '" Save "' '"'dst_path'"'
  507.   if (RC=5) then exit
  508.   parse var result wfl_file
  509.   if (upper(right(wfl_file,5))~='.LIST') then wfl_file = wfl_file||'.list'
  510.   n = 0
  511.   if open('fl',wfl_file,'W') then do forever
  512.     parse var wfl_filelist file ';' wfl_filelist
  513.     if strip(file)='' then leave
  514.     call writeln('fl',file); n=n+1
  515.   end
  516.   else ErrorOut('Failed to open output file list file!')
  517.   call close('fl');
  518.   'REQUEST' '"Wrote' n 'file names to file list'NL'`'wfl_file'`."' '" Continue "'
  519. return 'OK'
  520.  
  521. /* Additional procedures ------------------ */
  522.  
  523. get_path: PROCEDURE
  524.   parse arg get_path_in
  525.   if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in))
  526.   else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in))
  527.   else get_path_back = ''
  528. return get_path_back
  529.  
  530. get_file: PROCEDURE
  531.   parse arg get_file_in
  532.   if lastpos('/',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos('/',get_file_in))
  533.   else if lastpos(':',get_file_in) ~= 0 then get_file_back = substr(get_file_in,1+lastpos(':',get_file_in))
  534.   else get_file_back = get_file_in
  535. return get_file_back
  536.  
  537. get_ext: PROCEDURE
  538.   parse arg get_ext_in
  539.   if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in))
  540.   else get_ext_back = ''
  541. return get_ext_back
  542.  
  543. get_base: PROCEDURE
  544.   parse arg get_base_in
  545.   if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
  546.   else get_base_back = get_base_in
  547. return get_base_back
  548.  
  549. add_mathlib: PROCEDURE
  550.   if ~show(L,'rexxmathlib.library') then do
  551.     if exists('LIBS:rexxmathlib.library') then do
  552.       if ~addlib('rexxmathlib.library',0,-30,0) then ,
  553.         'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "'
  554.     end /* lib found on disk */
  555.     else 'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "'
  556.   end /* lib exists in mem */
  557. return 'OK'
  558.  
  559. ErrorOut:
  560.   parse arg string
  561.   'REQUEST' '"'string'"' '" Abort "'
  562.   exit
  563. end
  564.  
  565. SYNTAX:
  566.   SYNTAX_RC = RC
  567.   'IE_TO_FRONT'
  568.   'PRIORITY_SET' '0'
  569.   'REQUEST' '"Internal error on line' SIGL||NL||,
  570.     'Error' SYNTAX_RC':' errortext(SYNTAX_RC)'"' '" Abort "'
  571.   EXIT
  572. RETURN 0
  573.